package com.obrempon.credit.market.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.obrempon.credit.market.R
import com.obrempon.module.adapter.ObremponRecyclerViewAdapter
import com.obrempon.module.adapter.ObremponViewHolderHelper
import org.json.JSONObject

/**
 * ObremponCredit
 * @Author wwdeng
 * @CreateTime: 2025/3/3 17:49
 * @Annotation：首页Tab适配器
 */
class ObremponMainTabApt(recyclerView: RecyclerView?) : ObremponRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.obrempon_main_item) {
    override fun setItemChildListener(helper: ObremponViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.mainTabItemLayout)
    }
    override fun fillData(helper: ObremponViewHolderHelper, position: Int, model: JSONObject) {
        val mainTabImageView = helper.getImageView(R.id.mainTabImageView)
        val txtMainTabTitle = helper.getTextView(R.id.txtMainTabTitle)
        txtMainTabTitle.text = model.optString("tabTitle")

        when(model.optBoolean("isSelect", false)){
            true -> {
                txtMainTabTitle.setTextColor(getColor(R.color.color_ff0569ff))
                mainTabImageView.setImageResource(model.optInt("tabSelectedIcon"))
            }
            else -> {
                txtMainTabTitle.setTextColor(getColor(R.color.color_ffadb4cc))
                mainTabImageView.setImageResource(model.optInt("tabNormalIcon"))
            }
        }
    }
}